#include "SoundManager.h"
SoundManager* SoundManager::_instance = NULL;

SoundManager* SoundManager::GetInst()
{
	if(SoundManager::_instance == NULL)
	{
		_instance = new SoundManager();
	}

	return _instance;
}
SoundManager::SoundManager()
{
	m_listBgSound.push_back(new FmodSound(EFFECT_SOUND,"Resource/sound/Message.wav"));
	m_listBgSound.push_back(new FmodSound(EFFECT_SOUND,"Resource/sound/Win.mp3"));
	m_listBgSound.push_back(new FmodSound(EFFECT_SOUND,"Resource/sound/Lose.mp3"));
	m_listBgSound.push_back(new FmodSound(EFFECT_SOUND,"Resource/sound/Particle.mp3"));
	m_listBgSound.push_back(new FmodSound(EFFECT_SOUND,"Resource/sound/Replay.mp3"));
	m_listBgSound.push_back(new FmodSound(EFFECT_SOUND,"Resource/sound/SelectButton.mp3"));

	m_listBgSound.push_back(new FmodSound(BACKGROUND_SOUND,"Resource/sound/Pucca.mp3"));
	m_listBgSound.push_back(new FmodSound(BACKGROUND_SOUND,"Resource/sound/Larva.mp3"));
}


SoundManager::~SoundManager(void)
{
	m_listBgSound.clear();
}

void SoundManager::PlaySound(char* SOUND_FILE_PATH)
{
	int size = m_listBgSound.size();

	for(int i = 0 ; i < size; ++i)
	{
		if(strcmp(m_listBgSound[i]->soundPath, SOUND_FILE_PATH) == 0)
		{
			m_listBgSound[i]->GPlaySound();
			m_listBgSound[i]->GUpdateSoundSystem();
			return;
		}
	}

}

void SoundManager::PauseBgSound(char* SOUND_FILE_PATH, bool isPause)
{
	int size = m_listBgSound.size();

	for(int i = 0 ; i < size; ++i)
	{
		if(strcmp(m_listBgSound[i]->soundPath, SOUND_FILE_PATH) == 0)
		{
			m_listBgSound[i]->GSetPaused(isPause);
			return;
		}
	}

}

bool SoundManager::CheckBgPause(char* SOUND_FILE_PATH)
{
	int size = m_listBgSound.size();

	for(int i = 0 ; i < size; ++i)
	{
		if(strcmp(m_listBgSound[i]->soundPath, SOUND_FILE_PATH) == 0)
		{
			return m_listBgSound[i]->GGetPaused();
		}
	}
}